<?php
	
class Admin_Model_Inbound extends Admin_Model_Db_Inbound
{
	public function fetchInboundCode($inbound_type,$inbound_warehouse_group_code)
	{		
		//lấy code mới nhất
		$code=($inbound_type==0?"N":"X")."-".$inbound_warehouse_group_code."-";
		$this->fetchRowAllBase("inbound_code LIKE '%$code%'","inbound_id DESC",$entry);
		$newest_inbound_code=$entry->inbound_code;
		$from=strrpos($newest_inbound_code,"-")+1;
		$array_tmp=explode("-", $tmp);
		$no=substr($newest_inbound_code, $from,strlen($newest_inbound_code)-5-$from);
		$no=$no+1;
		
		//xu lí năm
		$year=date("Y");
		
		//trả ra mã code
		$inbound_code=$code.$no."/".$year;
		return $inbound_code;
	}
	

}